package com.example.shop.domain;

import com.example.shop.bos.BaseEntity;
import com.example.shop.bos.BosSet;
import com.example.shop.bos.Bostype;
import com.sun.jndi.cosnaming.IiopUrl;
import lombok.Data;

import javax.persistence.*;
import java.util.HashSet;
import java.util.Set;

/**
 * Created by cx on 17-11-30.
 */
@Entity
@Table(name = "T_BUYER")
@Bostype("A04")
@Data
public class Buyer extends BaseEntity {

    private String name;

    private String address;

    private String openId;

    private String phone;

    @OneToMany(cascade = CascadeType.ALL, mappedBy = "parent", orphanRemoval = true, fetch = FetchType.EAGER)
    private Set<AddressItem> addressItems = new HashSet<>();

    public BosSet<AddressItem> getItems() {
        return new BosSet(this.addressItems, this);
    }
}
